<#include "/common/head.ftl">

<div id="error" style="display:none;"></div>

<form action="study/editReceipt.sgt" validator="study/validateReceipt.sgt" onsubmit="submitFormValidation(this);return false" onreset="$('error').hide();" >
	<input type="hidden" name="id" value="${receipt.id}"/>
	<input type="hidden" name="studentId" value="${receipt.student.id}"/>
	
	<table align="center" cellspacing="10" cellpadding="0">
			
				<tr>
					<td colspan="2" style="color:#655F8F;border-bottom:1px dashed green">
						<div style="font-weight:bold;float:left">Receipt Information</div>
						<div style="float:right">
							<a href="#" onclick="pp('receipt/printReceipt.sgt?id=${receipt.id}');">Print</a>
							- <a href="#" onclick="cc('receipt/showInfoOfferingReceipt.sgt?id=${receipt.id}');">Details</a>
							<@showWhen roles=['Administrating','Consulting']>
							- <a href="#" onclick="cc('study/showChangeMemberOffering.sgt?receiptId=${receipt.id}&offeringId=${receipt.offering.id}');">Move Student</a>
							- <a href="#" onclick="if(confirm('${i18n.getMessage('dialog.delete')}')) { cc('study/deleteReceipt.sgt?id=${receipt.id}&offeringId=${receipt.offering.id}'); }">Delete</a>
							</@showWhen>
						</div>
					</td>
				</tr>
			<tr>
				<td style="width:110px;font-weight:bold">${i18n.getMessage('studentName')}:</td>
				<td>${receipt.student.lastName} ${receipt.student.firstName}</td>
			</tr>
			<tr>
				<td style="font-weight:bold">${i18n.getMessage('dateOfBirth')}:</td>
				<td>${receipt.student.dateOfBirth?date}</td>
			</tr>
			<tr>
				<td style="font-weight:bold">${i18n.getMessage('level')}:</td>
				<td>
					<select name="levelId" id="levelId" style="width:205px" onchange="requestSelectOption('receipt/requestOfferingByLevelId.sgt', this, 'offeringId')">
							${request.setAttribute("levels", program.levels)}
							<optgroup label="${program.name}">
								<#list levels as level>
									<option value="${level.id}" <#if (level = receipt.offering.level)>selected</#if>>${level.name}</option>
								</#list>
							</optgroup>
					</select>
				</td>
			</tr>
			<tr>
				<td style="font-weight:bold">${i18n.getMessage('offering')}:</td>
				<td>
					<select id="offeringId" name="offeringId" style="width:205px">
						<#list receipt.offering.level.offerings as offering>
							<option value="${offering.id}" <#if (offering = receipt.offering)>selected</#if>>${offering.startDate?date}-${offering.endDate?date}#${offering.name}</option>
						</#list>
					</select>
				</td>
			</tr>
			<tr>
				<td style="font-weight:bold">${i18n.getMessage('receiptNumber')}:</td>
				<td><input type="text" readonly="readonly" name="number" value="${(receipt.number)!}" style="width:136px"/></td>
			</tr>
			<tr>
				<td style="font-weight:bold">${i18n.getMessage('date')}:</td>
				<td><input type="text" name="date" value="${(receipt.date?date)!}" style="width:200px"/></td>
			</tr>
			<tr>
			<td style="font-weight:bold">Discount Item:</td>
			<td>
				${(receipt.discountItem.name)!}, ${(receipt.discountItem2.name)!}
			</td>
		</tr>
		<tr>
			<td style="font-weight:bold">${i18n.getMessage('fee')}:</td>
			<td><input type="text" readonly="readonly" name="fee" value="${(receipt.fee.amount)!}" style="width:170px"/> ${i18n.getMessage('currency.vnd')}</td>
		</tr>
		<tr>
			<td style="font-weight:bold">${i18n.getMessage('cashier')}:</td>
			<td>
				<select name="cashierId" style="width:204px">
					<option></option>
					<#list cashiers as cashier>	
						<option value="${cashier.id}" <#if cashier = (receipt.cashier)!>selected</#if>>${(cashier.lastName)!} ${(cashier.firstName)!}</option>
					</#list>
				</select>
			</td>
		</tr>
		<tr>
			<td style="font-weight:bold">${i18n.getMessage('options')}:</td>
			<td><input type="checkbox" name="active" value="true" <#if receipt.active>checked</#if>/> ${i18n.getMessage('active')}</td>
		</tr>
		<tr>
			<td style="font-weight:bold;vertical-align:top">${i18n.getMessage('comment')}:</td>
			<td><textarea name="comment" style="width:280px;height:80px;">${(receipt.comment)!}</textarea></td>
		</tr>
		<@showWhen roles=['Administrating','Consulting']>
			<tr>
				<td class="name"></td>
				<td>
					<input type="submit" value="${i18n.getMessage('edit')}" class="button_style"/> 
					<input type="reset" value="${i18n.getMessage('reset')}" class="button_style"/> 
				</td>
			</tr>
		</@showWhen>
	</table>
</form>

<script>
	$('error').hide();
</script>